import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;

/* This program creates a file of integers, each row is a separate data set representing separate processes test values, 
 * the first number is when it enters the system, the following numbers alternate between the number of CPU cycles and wait cycles needed
 */
public class processSet {
	public static void main(String args[]) throws FileNotFoundException {
		File file;
		int data = 0; // data to write to file
		int outerrandomloopcontrol = ((int) ((Math.random() * 1000000000) % 1000) + 100); // outer
																						// loop
																						// bound
		if(outerrandomloopcontrol < 100)
			outerrandomloopcontrol = 100; // never less than 100 processes
		int randomloopcontrol = 0; // inner loop bound
		int iscpuprocess = 0; // to get 80% CPU heavy cycles
		PrintWriter output; // to write to file
		file = new File("bin/processset"); // file object
		output = new PrintWriter(file); // write object for file object
		for (int w = 0; w < outerrandomloopcontrol; w++) // number of processes,
															// each line in file
															// is a separate
															// process
		{
			iscpuprocess = (int) ((Math.random() * 1000000000) % 10); //
			randomloopcontrol = ((int) ((Math.random() * 1000000000) % 15) + 3); // number
				if(randomloopcontrol < 4)
					randomloopcontrol = 4;    // never less than 4, time enter,CPU,IO,CPU
			if(randomloopcontrol % 2 == 1)							    		// of
					randomloopcontrol	= randomloopcontrol	+ 1; //last is CPU  // alterations
																				// between
																				// CPU
																				// cycle
																				// and
																				// waiting
																				// cycles
			for (int i = 0; i < randomloopcontrol; i++) // inner loop to write
														// data values to a line
														// in the file
			{
				data = ((int) ((Math.random() * 1000000000) % 25) + 1); // never
																		// zero
																		// cycles
				if ((i % 2) == 1 && iscpuprocess >= 2) // even number entries
														// (but i starts at zero
														// so i odd is even
														// entry) are CPU
														// cycles, 0,1 is 20%,
														// 2,3,4,5,6,7,8,9 is
														// 80%
					data = (int) ((Math.random() * 1000000000) % 15) + 11; // at
																			// least
																			// 11
																			// CPU
																			// cycles
																			// per
																			// alteration
																			// if
																			// in
																			// the
																			// 80%
																			// for
																			// CPU
																			// bound
																			// processes
				if (i == 0) // first number is when process enters system
							// therefore larger range
					data = ((int) ((Math.random() * 1000000000) % 1000) + 1);
				output.append(Integer.toString(data) + ' '); // write data to
																// file
				if (i == (randomloopcontrol - 1)) // test if last number is
													// processed for this line
													// in file, go to next line
													// in file
					output.println();
			} // inner loop
		} // outer loop

	} // main
} // class
